<?php

// +----------------------------------------------------------------------
// | ThinkAdmin
// +----------------------------------------------------------------------
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
// +----------------------------------------------------------------------
// | 官方网站: http://demo.thinkadmin.top
// +----------------------------------------------------------------------
// | 开源协议 ( https://mit-license.org )
// +----------------------------------------------------------------------
// | gitee 代码仓库：https://gitee.com/zoujingli/ThinkAdmin
// | github 代码仓库：https://github.com/zoujingli/ThinkAdmin
// +----------------------------------------------------------------------

namespace app\admin\controller;

use app\admin\service\NodeService;
use library\Controller;
use library\tools\Data;
use think\Console;
use think\Db;
use think\exception\HttpResponseException;
use app\common\facade\TransItem;
use app\common\facade\Arr;

/**
 * 标签配置
 * Class Index
 * @package app\admin\controller
 */
class Tag extends Controller
{
     protected $table = 'Tag';

    /**
     * 标签列表
     * @auth true
     * @menu true
     */
    public function index()
    {
         //标签
        $transtag= TransItem::transTag();
        $this->assign('transtag',$transtag);


        $this->title = '标签列表';
        $query = $this->_query($this->table)->like('name')->equal('tag_name,is_deleted,type');
        $query->order('sort desc,id desc')->page();


    }
    /**
     * 数据列表处理
     * @param array $data
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    protected function _index_page_filter(&$data)
    {
        foreach ($data as &$vo) {
            $vo['type'] = TransItem::transTag(Arr::get($vo, 'type'));
        }
    }

    /**
     * 添加标签
     * @auth true
     */
    public function tagAdd()
    {   
        //标签
        $transtag= TransItem::transTag();
        $this->assign('transtag',$transtag);

        $this->title = '添加标签';
        $this->_form($this->table, 'tag_add');
       
    }
    /**
     * 编辑标签
     * @auth true
     */
    public function edit()
    {   
        //标签
        $transtag= TransItem::transTag();
        $this->assign('transtag',$transtag);

        $this->title = '编辑标签';
        $this->_form($this->table, 'tag_add');
       
    }

     /**
       * 标签禁用
       * @auth true
     */
     public function forbid()
    {
        $this->_save($this->table, ['is_deleted' => '0']);
    }

    /**
       * 标签启用
       * @auth true
     */
    public function resume()
    {
        $this->_save($this->table, ['is_deleted' => '1']);
    }



}
